/**
* @file 金币提现
* @author 田
* @created 2023/7/05 08:00
* @updated 2023/7/05 18:00
*/
<template>
	<view class="tix">
		<u-navbar :border-bottom="false" title-size="35" title="提现"></u-navbar>
		<view class="tix-box">
			<view class="tix-cont">
				<view>提现金币数量</view>
				<view>
					<text>¥</text>
					<input type="text" v-model="val1">
					<text class="miaos" @click="qbtx">全部提现</text>
				</view>
				<view>
					<text>提现金币数量:{{user_info.money}}</text>
					<text>提现扣取3%手续费</text>
				</view>
			</view>
			<view class="tix-guiz">
				<u-checkbox @change="checkboxChange" v-model="checked" shape="circle" size="30">
					<view class="guiz-text">
						<text>我已阅读并同意</text>
						<text @click="goPolicy">《提现规则》</text>
					</view>
				</u-checkbox>
			</view>
			<view class="tix-btn" @click="tix">提现</view>
		</view>
		<!-- 输入框示例 -->
		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog ref="inputClose" mode="input" title="请输入交易端ID" value="" placeholder="请输入内容"
				@confirm="dialogInputConfirm" @close="closere"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import {
		getUserinfo,
	} from '@/network/loginAndMy.js'
	import {
		withPrice,
	} from '@/network/api.js'
	export default {
		data() {
			return {
				// 是否选中
				checked: false,
				value: '',
				val1: '',
				user_info:{},
				shouxf:''
			}
		},
		onLoad() {
			this.getUserinfoRe()
			this.getwithdrawalRe()
		},
		onShow() {
			this.getUserinfoRe()
		},
		methods: {
			// 获取手续费
			getwithdrawalRe(){
				getwithdrawal().then(res=>{
					this.shouxf=res.data
				})
			},
			// 获取用户信息
			getUserinfoRe() {
				getUserinfo().then(res => {
					if (res.code == 1) {
						this.user_info = res.data
						// console.log(this.user_info.ispass,'入金')
					}
				})
			},
			checkboxChange() {
				this.checked = !this.checked
			},
			// 全部提现
			qbtx(){
				this.val1=this.user_info.money
			},
			// 打开弹框
			tix() {
				if(this.val1==''){
					uni.showToast({
					    title: "请填写交易金额",
					    icon: "none",
					    duration: 2000,
					});
				}else if(this.val1 < 1){
					uni.showToast({
					    title: "最低提现金币：1",
					    icon: "none",
					    duration: 2000,
					});
				}else if(!this.checked){
					uni.showToast({
					    title: "请勾选提现协议",
					    icon: "none",
					    duration: 2000,
					});
				}else{
					this.dialogInputConfirm()
					// this.$refs.inputDialog.open()
				}
			},
			// 弹框确认
			dialogInputConfirm() {
				// if(e==''){
				// 	uni.showToast({
				// 	    title: "请填写交易端ID",
				// 	    icon: "none",
				// 	    duration: 2000,
				// 	});
				// }else{
					let data={
						money:this.val1,
						// payid:e
					}
					withPrice(data).then(res=>{
						if(res.code==1){
							uni.showToast({
							    title: "提现成功",
							    icon: "none",
							    duration: 2000,
							});
							
							setTimeout(()=>{
								uni.reLaunch({
									url:'/pages/main/my/my'
								})
							},1000)
						}
					})
				// }
			},
			// 跳转隐私协议
			goPolicy() {
				uni.navigateTo({
					url: '/pages/subpackage/my/policy?type='+4
				})
			},
			// 弹框取消
			closere(){
				
			}
		}
	}
</script>

<style lang="scss">
	.tix {
		height: 100vh;
		background-color: #f3f3f3;

		.tix-box {
			.tix-cont {


				height: 256rpx;
				margin-top: 20rpx;
				padding: 20rpx 30rpx;
				background-color: #fff;

				>view:nth-child(1) {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					color: #333333;
				}

				>view:nth-child(2) {
					display: flex;
					align-items: center;
					margin: 40rpx 0;
					border-bottom: 1rpx solid #E5E5E5;

					>text:nth-child(1) {
						font-size: 36rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						color: #333333;
					}

					input {
						width: 400rpx;
						margin: 0 20rpx;
						font-size: 48rpx;
						font-family: PingFang SC, PingFang SC-Bold;
					}

					.miaos {
						margin-left: auto;
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						color: #b27715;
					}

					.miaos:active {
						color: #000
					}
				}

				>view:nth-child(3) {
					display: flex;
					margin: 20rpx 0;
					justify-content: space-between;

					>text:nth-child(1) {
						display: block;
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
					}

					>text:nth-child(2) {
						display: block;
						font-size: 24rpx;
						color: #B27715;
						font-family: PingFang SC, PingFang SC-Medium;
					}
				}
			}

			.tix-guiz {
				margin: 40rpx 30rpx;

				.guiz-text {
					text {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
					}

					>text:nth-child(2) {
						color: #B27715
					}
				}
			}

			.tix-btn {
				width: 690rpx;
				height: 90rpx;
				line-height: 90rpx;
				margin: 0 auto;
				text-align: center;
				font-size: 36rpx;
				color: #fff;
				font-family: PingFang SC, PingFang SC-Medium;
				border-radius: 10rpx;
				background: linear-gradient(to right, #B07412, #E3BA5B);
			}

			.tix-btn:active {
				background: linear-gradient(to right, #E3BA5B, #B07412);
			}
		}
	}
</style>